package com.aaa.mbs.controller;

import com.aaa.common.constants.ReturnStatus;
import com.aaa.common.util.Result;
import com.aaa.mbs.entity.IntegrationHistory;
import com.aaa.mbs.entity.MemberLevel;
import com.aaa.mbs.service.IntegrationHistoryService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (IntegrationHistory)表控制层
 *
 * @author makejava
 * @since 2020-12-05 10:04:51
 */
@RestController
@RequestMapping("integrationHistory")
public class IntegrationHistoryController {
    /**
     * 服务对象
     */
    @Resource
    private IntegrationHistoryService integrationHistoryService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    @ApiOperation("通过主键查询单条数据")
    public IntegrationHistory selectOne(Long id) {
        return this.integrationHistoryService.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param pageNo 查询起始位置
     * @param pageSize  查询条数
     * @return 对象列表
     */
    @GetMapping("queryAllByParam")
    public Result queryAllByParam(Integer pageNo, Integer pageSize,String clientName) {
        IntegrationHistory integrationHistory = new IntegrationHistory();
        integrationHistory.setClientName(clientName);
        return this.integrationHistoryService.queryAllByParam (pageNo,pageSize,integrationHistory);
    }

    /**
     * 根据ID删除
     *
     * @param id id
     * @return Result
     */
    @DeleteMapping("deleteById")
    @ApiOperation("根据ID删除")
    public Result deleteById(Long id) {
        return new Result(ReturnStatus.SUCCESS.getReturnCode(),
                ReturnStatus.SUCCESS.getReturnMsg(), this.integrationHistoryService.deleteById(id));
    }

    /**
     * 更新
     *
     * @param @param integrationHistory 实例对象
     * @return Result
     */
    @PutMapping("update")
    @ApiOperation("更新")
    public Result update(@ApiParam("更新json数据") @RequestBody IntegrationHistory integrationHistory) {
        return new Result(ReturnStatus.SUCCESS.getReturnCode(),
                ReturnStatus.SUCCESS.getReturnMsg(), this.integrationHistoryService.update(integrationHistory));
    }

    /**
     * 添加
     *
     * @param @param integrationHistory 实例对象
     * @return Result
     */
    @PostMapping("insert")
    @ApiOperation("添加")
    public Result insert(@ApiParam("添加json数据") @RequestBody IntegrationHistory integrationHistory) {
        return new Result(ReturnStatus.SUCCESS.getReturnCode(),
                ReturnStatus.SUCCESS.getReturnMsg(), this.integrationHistoryService.insert(integrationHistory));
    }
}